<?php
// 获取维修员的待完成任务
// header("content-type:text/html;charset=utf-8");
include_once("conn.php");
if (!session_id()) {
    session_start();
}

$sql = "SELECT * FROM tb_fix_repairer 
    INNER JOIN tb_fixinfo_request ON tb_fix_repairer.fix_id = tb_fixinfo_request.fix_id
    AND tb_fix_repairer.r_id = '" . $_SESSION['REPAIRER']['r_id'] . "' 
    AND tb_fixinfo_request.fix_status = '1'
    ORDER BY tb_fix_repairer.r_date DESC";
if ($res = mysqli_query($conn_DB, $sql)) {
    $num = mysqli_num_rows($res);
}
function show_info()
{
    global $conn_DB;
    global $sql;
    $result = mysqli_query($conn_DB, $sql);
    if ($result) {
        $count = 0;
        if (mysqli_num_rows($result) <= 0) {
            echo "<div class='none-info'>暂未接收到维修任务</div>";
        } else {
            while ($row = mysqli_fetch_object($result)) {
                if ($count % 4 == 0) {
                    echo "<div class='content-item'>";
                }
                echo "<div class='content-items'>
                    <div class='content-items-list'>
                        <div class='over_fix'>
                            <form method='get' action='php/deal.php'>
                                <input type='hidden' name='fix_id' value='" . $row->fix_id . "'>
                                <input type='hidden' name='action' value='over_fix'>
                                <button type='submit' class='btn btn-outline-success' onclick = 'return over_fix();'>维修完成</button>
                            </form>
                        </div>
                        <div class='content-items-lists'>
                            <span>报修单号：</span>" . $row->fix_id . "
                        </div>
                        <div class='content-items-lists'>
                            <span>报修人：</span>" . $row->fix_name . "
                        </div>
                        <div class='content-items-lists'>
                            <span>联系电话：</span>" . $row->fix_phone . "
                        </div>
                        <div class='content-items-lists'>
                            <span>报修时间：</span>" . $row->fix_sendtime . "
                        </div>
                        <div class='content-items-lists'>
                            <span>报修类型：</span>" . $row->fix_type . "
                        </div>
                        <div class='content-items-lists'>
                            <span>地点区域：</span>" . $row->fix_area . "
                        </div>
                        <div class='content-items-lists'>
                            <span>详细地址：</span>" . $row->fix_address . "
                        </div>
                        <div class='content-items-lists'>
                            <span>损坏原因：</span>" . $row->fix_reason . "
                        </div>
                        <div class='content-items-lists'>
                            <span>故障描述：</span>" . $row->fix_depicted . "
                        </div>
                        <div class='content-items-lists img-lists'>
                            故障图<br>
                            <img src='../img/user_upload/" . $row->fix_img . "' alt='QAQ图片找不到啦~'>
                        </div>
                    </div></div>";
                $count++;
                if ($count % 4 == 0) {
                    echo "</div>";
                }
            }
        }
    } else {
        echo "<div class='none-info'>数据错误</div>";
    }
}
